﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Web;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting;
using System.Web.Services;
using System.IO;
using System.Collections;
using System.ServiceModel.Activation;
using System.ServiceModel.Description;
using System.Threading;
using System.Diagnostics;
using System.Reflection;
using System.Web.SessionState;

using PickGold.Base.Proxies;

namespace PickGold.Base.Remoting
{
	/// <summary>
	/// 方法代理执行接口
	/// </summary>
	[ComVisible(true)]
	[ServiceContract(Namespace = "hsj://hong.shi.jin/method-invoker/")]
	public interface IMethodInvoker
	{
		/// <summary>
		/// 调用远程方法；
		/// </summary>
		/// <param name="message">消息</param>
		/// <returns>结果消息</returns>
		[OperationContract]
		byte[] Invoke(byte[] message);

		/// <summary>
		/// 开始异步调用远程方法
		/// </summary>
		/// <param name="message">消息</param>
		/// <param name="callback">回调方法</param>
		/// <param name="state">异步状态数据</param>
		/// <returns>异步操作状态</returns>
		[OperationContract(AsyncPattern = true)]
		IAsyncResult BeginAsyncInvoke(byte[] message, AsyncCallback callback, object state);

		/// <summary>
		/// 异步调用远程方法结束
		/// </summary>
		/// <param name="result">异步操作状态</param>
		/// <returns>结果消息</returns>
		byte[] EndAsyncInvoke(IAsyncResult result);

		/// <summary>
		/// 取指定时间或服务器全球时间，一般用作测试；
		/// </summary>
		/// <param name="dateTime">时间字符串，可为空；</param>
		/// <returns>传入的时间或服务器的全球时间；</returns>
		[OperationContract]
		DateTime GetDateTime(string dateTime);
	}

	/// <summary>
	/// 双向方法代理执行接口
	/// </summary>
	[ComVisible(true)]
	[ServiceContract(CallbackContract = typeof(IMethodInvoker), Namespace = "hsj://hong.shi.jin/method-invoker-duplex/")]
	public interface IMethodInvokerDuplex : IMethodInvoker
	{
	}

	interface ICloseable
	{
		void Close();
	}

	interface IMethodInvokerClient : ICloseable, IMethodInvoker, IMethodInvokerDuplex
	{
	}
}
